//  OrderListVC.m
//  XJMCustomer
//  Created by Mr.hu on 2017/10/13.
//  Copyright © 2017年 Mr.hu. All rights reserved.

#import "OrderListVC.h"
#import "UnderWayTBVCell.h"
#import "ApplyRefundSecond.h"
#import "ExchangeDiscounts.h"
#import "DeleteExchangeDiscount.h"

#import "RefundStatusPay.h" //退款详情
#import "CurrentOrder_Arrive.h"
#import "CurrentServiceVC.h"

@interface OrderListVC ()<UITableViewDataSource,UITableViewDelegate>

@property (weak) IBOutlet NSLayoutConstraint *lineConstraint;
@property (weak, nonatomic) IBOutlet UITableView *UnderWayTBV;
@property (nonatomic) NSInteger selectStatus;//1 进行中 2已完成 3取消
/** 注释 **/
@property (strong, nonatomic) NSMutableArray * OrderAllArr;
/** 注释 **/
@property (strong, nonatomic) ExchangeDiscounts * exchangeDiscts;
/** 注释 **/
@property (strong, nonatomic) DeleteExchangeDiscount * exchangeDelete;
@property (weak, nonatomic) IBOutlet UIView *Without_OrderView;
@property (weak, nonatomic) IBOutlet UIButton *Without_strollBtn;

@property (nonatomic) NSInteger page;
//选择的状态
@property (nonatomic) NSInteger SelectStatInt;
@property (strong, nonatomic) IBOutlet UIView *Order_backView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Height_viewtop;

@end

@implementation OrderListVC

- (void)viewWillAppear:(BOOL)animated{
    [self.navigationController setNavigationBarHidden:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"我的订单";
    //控制器中这么设置也可以
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16.f],NSForegroundColorAttributeName:[UIColor blackColor]}];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(0, 0, 40, 40);
    [btn setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:14];
    [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
    [btn addTarget:self action:@selector(backToPrevious) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
    
    if ([[XJToolClass iphoneType] isEqualToString:@"iPhone X"]) {
        self.Height_viewtop.constant+=20;
    }
    
    [self.Without_strollBtn removeFromSuperview]; //删除去逛逛
    
    [self orderListTableView];
    
    if ([XJToolClass getUserId]) {
    
    self.OrderrouteType = 0;
    
    [self setBtnType:0];
    self.UnderWayTBV.backgroundColor = RGBA(230, 230, 230, 1);
        
    __weak typeof(self)weakSelf = self;
    //待处理不是同一个接口 单独拿出来
    if (self.OrderrouteType == 1) {
        
        self.page=1;
        self.UnderWayTBV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{

            [self AwaitDealOrderRequest:1];
            [self.UnderWayTBV.mj_header endRefreshing];
        }];
        
        self.UnderWayTBV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
            [self AwaitDealOrderRequestPullDown:++self.page ];
            [self.UnderWayTBV.mj_footer endRefreshing];
        }];
        self.UnderWayTBV.mj_footer.automaticallyHidden = YES;
        [self AwaitDealOrderRequest:1];
        
    }else{
    
    [self OrderServerRequest:1];
        
    self.page=1;
    self.UnderWayTBV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        if (weakSelf.OrderrouteType == 1) {
            [self AwaitDealOrderRequest:1];
        }else{
            [self OrderServerRequest:1];
        }
        
            [self.UnderWayTBV.mj_header endRefreshing];
    }];
        
    self.UnderWayTBV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        [self OrderServerRequestPulldown:++self.page ];
        [self.UnderWayTBV.mj_footer endRefreshing];
    }];
    self.UnderWayTBV.mj_footer.automaticallyHidden = YES;
        
        }
    }
}

- (IBAction)BackOrderListMeth:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)OrderServerRequestPulldown:(NSInteger)pullpage{
    
     NSMutableArray * pulldownarr = [NSMutableArray array];
    
    [XJHttpClass OrderListMineType:[NSString stringWithFormat:@"%ld",self.OrderrouteType] page:[NSString stringWithFormat:@"%ld",pullpage] token:[XJToolClass getToken] andFinishblock:^(id response, NSString *errStr) {
        
        if (errStr) {
            [self.UnderWayTBV.mj_footer endRefreshingWithNoMoreData];
        }else{
            
            [pulldownarr addObject: response[@"data"]];
            if (self.OrderAllArr.count > 0) {
                [self.OrderAllArr addObject:pulldownarr];
                self.Without_OrderView.hidden = YES;
                [self.UnderWayTBV reloadData];
            }else{
                [self.UnderWayTBV.mj_footer endRefreshingWithNoMoreData];
                self.Without_OrderView.hidden = NO;
                self.Without_strollBtn.layer.cornerRadius = 22;
                self.Without_strollBtn.layer.masksToBounds = YES;
            }
        }
    }];
}

- (void)OrderServerRequest:(NSInteger)selectStatus{
    
    self.selectStatus = selectStatus;
    
    if ([XJToolClass getToken]) {
    
        [LoadingView showCircleView:self.view];
        
        [XJHttpClass OrderListMineType:[NSString stringWithFormat:@"%ld",self.OrderrouteType] page:@"1" token:[XJToolClass getToken] andFinishblock:^(id response, NSString *errStr) {
            [LoadingView hide];
            if (errStr) {
                self.Without_OrderView.hidden = NO;
            }else{
                
                self.OrderAllArr = response[@"data"];
                
                if (self.OrderAllArr.count > 0) {
                  
                    self.Without_OrderView.hidden = YES;
                    
                }else{
                    
                    self.Without_OrderView.hidden = NO;
                    self.Without_strollBtn.layer.cornerRadius = 22;
                    self.Without_strollBtn.layer.masksToBounds = YES;
                }
                
                [self.UnderWayTBV reloadData];
            }
        }];
    }
}

//待处理单独拿出来
-(void)AwaitDealOrderRequest:(NSInteger)selectStatus{
    
    [self.OrderAllArr removeAllObjects];
    [LoadingView showCircleView:self.view];
    [XJHttpClass ExitPayListToken:[XJToolClass getToken] page:@"1" andFinishblock:^(id response, NSString *errStr) {
        [LoadingView hide];
        if (errStr) {
            self.Without_OrderView.hidden = NO;
        }else{
            
            self.OrderAllArr = response[@"data"];
            
            if (self.OrderAllArr.count > 0) {
                
                self.Without_OrderView.hidden = YES;
                [self.UnderWayTBV reloadData];
                
            }else{
                
                self.Without_OrderView.hidden = NO;
                self.Without_strollBtn.layer.cornerRadius = 22;
                self.Without_strollBtn.layer.masksToBounds = YES;
            }
        }
    }];
}

-(void)AwaitDealOrderRequestPullDown:(NSInteger)selectStatus{
    
    NSMutableArray * pulldownarr = [NSMutableArray array];
    [XJHttpClass ExitPayListToken:[XJToolClass getToken] page:[NSString stringWithFormat:@"%ld",selectStatus] andFinishblock:^(id response, NSString *errStr) {
        
        if (errStr) {
            [self.UnderWayTBV.mj_footer endRefreshingWithNoMoreData];
        }else{
            
            [pulldownarr addObject: response[@"data"]];
            if (pulldownarr.count > 0) {
                [self.OrderAllArr addObject:pulldownarr];
                self.Without_OrderView.hidden = YES;
                [self.UnderWayTBV reloadData];
                
            }else{
                
                [self.UnderWayTBV.mj_footer endRefreshingWithNoMoreData];
                self.Without_OrderView.hidden = NO;
                self.Without_strollBtn.layer.cornerRadius = 22;
                self.Without_strollBtn.layer.masksToBounds = YES;
            }
        }
    }];
}

- (void)orderListTableView{
    
    self.UnderWayTBV.delegate = self;
    self.UnderWayTBV.dataSource = self;
    self.UnderWayTBV.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.UnderWayTBV registerNib:[UINib nibWithNibName:@"UnderWayTBVCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"UnderWayTBVCell"];
}

#pragma mark - TableViewDatasource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if ([self.OrderAllArr isKindOfClass:[NSMutableArray class]]) {
        
        return self.OrderAllArr.count;
        
    }else{
        return 0;
    }
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UnderWayTBVCell * friend=[tableView dequeueReusableCellWithIdentifier:@"UnderWayTBVCell" forIndexPath:indexPath];
    
    if(friend==nil){
        friend=[[UnderWayTBVCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UnderWayTBVCell"];
    }
    
    friend.selectionStyle = UITableViewCellSelectionStyleNone;
    friend.userInteractionEnabled = YES;
    friend.OrderContiunePay.tag = indexPath.row;
    friend.OrderCancelOrderList.tag = indexPath.row;
    friend.OrderContiunePay.layer.cornerRadius =3;
    friend.OrderContiunePay.layer.masksToBounds = YES;
    friend.OrderCancelOrderList.layer.borderColor = RGBA(230, 230, 230, 1).CGColor;
    friend.OrderCancelOrderList.layer.borderWidth = 1;
    friend.OrderCancelOrderList.layer.cornerRadius =3;
    friend.OrderCancelOrderList.layer.masksToBounds = YES;
    friend.OrderCancelOrderList.hidden = YES;
    
    if (self.OrderrouteType == 0) { //进行中
        
        friend.OrderBottom_View.hidden = NO;
        NSString * order_id = [NSString stringWithFormat:@"%@",self.OrderAllArr[indexPath.row][@"date_type"]];
        
        if ([order_id isEqualToString:@"0"]) {
            
            [friend.OrderContiunePay addTarget:self action:@selector(ApplyExitMoneyMeth:) forControlEvents:UIControlEventTouchUpInside];
            [friend.OrderContiunePay setTitle:@"立即前往" forState:UIControlStateNormal];
            [friend.OrderContiunePay setTitleColor:DefaultRedRGB forState:UIControlStateNormal];
            friend.OrderContiunePay.backgroundColor = [UIColor whiteColor];
            friend.OrderContiunePay.layer.borderColor = [UIColor colorWithRed:(213)/255.0 green:(32)/255.0 blue:(30)/255.0 alpha:(1)].CGColor;
            friend.OrderContiunePay.layer.borderWidth = 0.6;
            friend.OrderContiunePay.enabled = YES;
            friend.OrderCancelOrderList.hidden = YES;
            friend.OrderDealStatus.text = @"即时上门";
            friend.OrderDealStatus.textColor = RGBA(51, 51, 51, 51);
            friend.OrderTotalPrice.textColor = RGBA(51, 51, 51, 51);
            
        }else if ([order_id isEqualToString:@"1"]){ // 1预约今天
            
            [friend.OrderContiunePay setTitle:@"立即前往" forState:UIControlStateNormal];
            [friend.OrderContiunePay addTarget:self action:@selector(ApplyExitMoneyMeth:) forControlEvents:UIControlEventTouchUpInside];
            [friend.OrderContiunePay setTitleColor:RGBA(153, 153, 153, 1) forState:UIControlStateNormal];
            friend.OrderContiunePay.backgroundColor = [UIColor whiteColor];
            friend.OrderContiunePay.layer.borderColor = [UIColor colorWithRed:(153)/255.0 green:(153)/255.0 blue:(153)/255.0 alpha:(1)].CGColor;
            friend.OrderContiunePay.layer.borderWidth = 0.6;
            friend.OrderContiunePay.enabled = NO;
            friend.OrderCancelOrderList.hidden = YES;
            friend.OrderDealStatus.text = @"预约中";
            friend.OrderDealStatus.textColor = RGBA(213, 32, 30, 1);
            friend.OrderTotalPrice.textColor = RGBA(213, 32, 30, 1);
            
        }else if ([order_id isEqualToString:@"2"]){
            
            [friend.OrderContiunePay setTitle:@"立即前往" forState:UIControlStateNormal];
            [friend.OrderContiunePay addTarget:self action:@selector(ApplyExitMoneyMeth:) forControlEvents:UIControlEventTouchUpInside];
            [friend.OrderContiunePay setTitleColor:RGBA(153, 153, 153, 1) forState:UIControlStateNormal];
            friend.OrderContiunePay.backgroundColor = [UIColor whiteColor];
            friend.OrderContiunePay.layer.borderColor = [UIColor colorWithRed:(153)/255.0 green:(153)/255.0 blue:(153)/255.0 alpha:(1)].CGColor;
            friend.OrderContiunePay.layer.borderWidth = 0.6;
            friend.OrderContiunePay.enabled = NO;
            friend.OrderCancelOrderList.hidden = YES;
            friend.OrderDealStatus.text = @"预约中";
            friend.OrderDealStatus.textColor = RGBA(213, 32, 30, 1);
            friend.OrderTotalPrice.textColor = RGBA(213, 32, 30, 1);
            
        }else if ([order_id isEqualToString:@"3"]){ //3服务进行中
            
            [friend.OrderContiunePay setTitle:@"立即前往" forState:UIControlStateNormal];
            [friend.OrderContiunePay addTarget:self action:@selector(ApplyExitMoneyMeth:) forControlEvents:UIControlEventTouchUpInside];
            [friend.OrderContiunePay setTitleColor:DefaultRedRGB forState:UIControlStateNormal];
            friend.OrderContiunePay.backgroundColor = [UIColor whiteColor];
            friend.OrderContiunePay.layer.borderColor = [UIColor colorWithRed:(254)/255.0 green:(153)/255.0 blue:(9)/255.0 alpha:(1)].CGColor;
            friend.OrderContiunePay.layer.borderWidth = 0.6;
            friend.OrderContiunePay.enabled = YES;
            friend.OrderCancelOrderList.hidden = YES;
            friend.OrderDealStatus.text = @"进行中";
            friend.OrderDealStatus.textColor = RGBA(213, 32, 30, 1);
            friend.OrderTotalPrice.textColor = RGBA(213, 32, 30, 1);
            
        }
        
        [friend setData:self.OrderAllArr[indexPath.row]];
        
    }else if (self.OrderrouteType == 1){ //待处理
        
        friend.OrderBottom_View.hidden = NO;
        //待处理单独拿出来
        if (self.OrderAllArr.count > 0) {
            
        NSString * order_exitID = [NSString stringWithFormat:@"%@",self.OrderAllArr[indexPath.row][@"status"]];
        if ([order_exitID isEqualToString:@"0"]) {  //0已确认
            
            friend.OrderDealStatus.text = @"已确认";
            friend.OrderDealStatus.textColor = DefaultRedRGB;
            friend.OrderTotalPrice.textColor = DefaultRedRGB;
            
            [friend.OrderContiunePay setTitle:@"查看详情" forState:UIControlStateNormal];
            friend.OrderContiunePay.tag = indexPath.row;
            [friend.OrderContiunePay addTarget:self action:@selector(CheckDetailPageMeth:) forControlEvents:UIControlEventTouchUpInside];
            [friend.OrderContiunePay setTitleColor:DefaultRedRGB forState:UIControlStateNormal];
            friend.OrderContiunePay.backgroundColor = [UIColor whiteColor];
            friend.OrderContiunePay.layer.borderColor = [UIColor colorWithRed:(213)/255.0 green:(32)/255.0 blue:(30)/255.0 alpha:(1)].CGColor;
            friend.OrderContiunePay.layer.borderWidth = 0.6;
            friend.OrderContiunePay.enabled = YES;
            friend.OrderContiunePay.hidden = NO;
        }else if ([order_exitID isEqualToString:@"1"]){  //1未确认
            friend.OrderDealStatus.text = @"未确认";
            friend.OrderDealStatus.textColor = DefaultRedRGB;
            friend.OrderTotalPrice.textColor = DefaultRedRGB;
            
            [friend.OrderContiunePay setTitle:@"查看详情" forState:UIControlStateNormal];
            friend.OrderContiunePay.tag = indexPath.row;
            [friend.OrderContiunePay addTarget:self action:@selector(CheckDetailPageMeth:) forControlEvents:UIControlEventTouchUpInside];
            [friend.OrderContiunePay setTitleColor:RGBA(213, 32, 30, 1) forState:UIControlStateNormal];
            friend.OrderContiunePay.backgroundColor = [UIColor whiteColor];
            friend.OrderContiunePay.layer.borderColor = [UIColor colorWithRed:(213)/255.0 green:(32)/255.0 blue:(30)/255.0 alpha:(1)].CGColor;
            friend.OrderContiunePay.layer.borderWidth = 0.6;
            friend.OrderContiunePay.enabled = YES;
            
        }else if ([order_exitID isEqualToString:@"2"]){ //2已拒绝
            friend.OrderDealStatus.text = @"已拒绝";
            friend.OrderDealStatus.textColor = RGBA(213, 32, 30, 1);
            friend.OrderTotalPrice.textColor = RGBA(213, 32, 30, 1);
            [friend.OrderContiunePay setTitle:@"查看详情" forState:UIControlStateNormal];
            friend.OrderContiunePay.tag = indexPath.row;
            [friend.OrderContiunePay addTarget:self action:@selector(CheckDetailPageMeth:) forControlEvents:UIControlEventTouchUpInside];
            [friend.OrderContiunePay setTitleColor:RGBA(213, 32, 30, 1) forState:UIControlStateNormal];
            friend.OrderContiunePay.backgroundColor = [UIColor whiteColor];
            friend.OrderContiunePay.layer.borderColor = [UIColor colorWithRed:(213)/255.0 green:(32)/255.0 blue:(30)/255.0 alpha:(1)].CGColor;
            friend.OrderContiunePay.layer.borderWidth = 0.6;
            friend.OrderContiunePay.enabled = YES;
        }else if ([order_exitID isEqualToString:@"3"]){  //3已完成退款
            friend.OrderDealStatus.text = @"已完成";
            friend.OrderDealStatus.textColor = DefaultgrayRGB;
            friend.OrderTotalPrice.textColor = DefaultgrayRGB;
            [friend.OrderContiunePay setTitle:@"查看详情" forState:UIControlStateNormal];
            [friend.OrderContiunePay addTarget:self action:@selector(CheckDetailPageMeth:) forControlEvents:UIControlEventTouchUpInside];
            [friend.OrderContiunePay setTitleColor:RGBA(153, 153, 153, 1) forState:UIControlStateNormal];
            friend.OrderContiunePay.backgroundColor = [UIColor whiteColor];
            friend.OrderContiunePay.layer.borderColor = [UIColor colorWithRed:(153)/255.0 green:(153)/255.0 blue:(153)/255.0 alpha:(1)].CGColor;
            friend.OrderContiunePay.layer.borderWidth = 0.6;
            friend.OrderContiunePay.enabled = NO;
        }
            
            [friend setData:self.OrderAllArr[indexPath.row]];
        }
    }else if (self.OrderrouteType == 2){ //已完成
        
        friend.OrderBottom_View.hidden = YES;
        friend.OrderDealStatus.text = @"已完成";
        [friend setData:self.OrderAllArr[indexPath.row]];
        friend.OrderDealStatus.textColor = DefaultgrayRGB;
        friend.OrderTotalPrice.textColor = [UIColor blackColor];
        
    }else if (self.OrderrouteType == 3){ //已取消
        
        friend.OrderBottom_View.hidden = YES;
        friend.OrderDealStatus.text = @"已取消";
        friend.OrderDealStatus.textColor = DefaultgrayRGB;
        friend.OrderTotalPrice.textColor = [UIColor blackColor];
        
        [friend setData:self.OrderAllArr[indexPath.row]];
        
    }
    
    return friend;
}

- (void)CheckDetailPageMeth:(UIButton *)sender{
    
    //待处理单独拿出来
    NSString * order_exitID = [NSString stringWithFormat:@"%@",self.OrderAllArr[sender.tag][@"status"]];
    if ([order_exitID isEqualToString:@"0"]) {  //0已确认
        
        RefundStatusPay * refund = [[RefundStatusPay alloc]init];
        refund.SubmitExit_Status = [NSString stringWithFormat:@"100"];
        refund.SubmitExit_OrderID = [NSString stringWithFormat:@"%@",self.OrderAllArr[sender.tag][@"id"]];
        [self.navigationController pushViewController:refund animated:YES];
    }else if ([order_exitID isEqualToString:@"1"]){ //1未确认
        RefundStatusPay * refund = [[RefundStatusPay alloc]init];
        refund.SubmitExit_Status = [NSString stringWithFormat:@"200"];
        refund.SubmitExit_OrderID = [NSString stringWithFormat:@"%@",self.OrderAllArr[sender.tag][@"id"]];
        [self.navigationController pushViewController:refund animated:YES];
    }else if  ([order_exitID isEqualToString:@"2"]){   //2已拒绝
        RefundStatusPay * refund = [[RefundStatusPay alloc]init];
        refund.SubmitExit_Status = [NSString stringWithFormat:@"300"];
        refund.SubmitExit_OrderID = [NSString stringWithFormat:@"%@",self.OrderAllArr[sender.tag][@"id"]];
        [self.navigationController pushViewController:refund animated:YES];
    }
}

#pragma mark TableViewDelegate
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (self.OrderrouteType == 0 || self.OrderrouteType == 1) {
        return 130+45;
    }else{
        return 130;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (IBAction)OrderListSelectMeth:(UIButton *)sender {
    
    [self setBtnType:sender.tag/100-1];
    if (sender.tag==100) {
        self.OrderrouteType=0;
        [self.OrderAllArr removeAllObjects];
        [self OrderServerRequest:0];  //进行中0
        [self.UnderWayTBV reloadData];
        
    }else if (sender.tag==200){
        self.OrderrouteType=1;
        [self.OrderAllArr removeAllObjects];
        [self AwaitDealOrderRequest:1]; //退款列表
        [self.UnderWayTBV reloadData];
        
    }else if (sender.tag==300){
        self.OrderrouteType = 2;
        [self.OrderAllArr removeAllObjects];
        [self OrderServerRequest:3]; //已完成2
        [self.UnderWayTBV reloadData];
        
    }else if (sender.tag == 400){
        self.OrderrouteType = 3;
        [self.OrderAllArr removeAllObjects];
        [self OrderServerRequest:4]; //已取消3
        [self.UnderWayTBV reloadData];
    }
}

//设置4个btn状态
-(void)setBtnType:(NSInteger)tag{
    
    self.lineConstraint.constant=ScreenWidth/4*tag;
    for (int i=1; i<5; i++) {
        UIButton *myButton = (UIButton *)[self.view viewWithTag:(i*100)];
        if (i==tag+1) {
            myButton.selected=YES;
        }else{
            myButton.selected=NO;
        }
    }
}

- (void)ApplyExitMoneyMeth:(UIButton *)sender{
    
    NSString * order_id = [NSString stringWithFormat:@"%@",self.OrderAllArr[sender.tag][@"date_type"]];
    
    if ([order_id isEqualToString:@"0"] ||[order_id isEqualToString:@"1"] ||[order_id isEqualToString:@"2"]) {
        
    CurrentOrder_Arrive * CurrentOrder = [[CurrentOrder_Arrive alloc]init];
    CurrentOrder.hidesBottomBarWhenPushed = YES;
    CurrentOrder.Customer_latitude = [NSString stringWithFormat:@"%@",self.OrderAllArr[sender.tag][@"u_lat"]];
    CurrentOrder.Customer_longtitude = [NSString stringWithFormat:@"%@",self.OrderAllArr[sender.tag][@"u_lon"]];
    CurrentOrder.CustomerOrder_Dict = self.OrderAllArr[sender.tag];
    [self.navigationController pushViewController:CurrentOrder animated:YES];
    }else if([order_id isEqualToString:@"3"]){
        
        CurrentServiceVC * currentservice = [[CurrentServiceVC alloc]init];
        currentservice.CurrentOrder_Information = self.OrderAllArr[sender.tag];
        currentservice.CurrentOrder_ID = self.OrderAllArr[sender.tag][@"order_id"];
        [self.navigationController pushViewController:currentservice animated:YES];
    }
    
    
}

//取消订单
- (void)CancelPayMentMeth:(UIButton *)sender{
    
    self.exchangeDiscts = [[ExchangeDiscounts alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    self.exchangeDiscts.backgroundColor = RGBA(102, 102, 102, 0.8);
    self.exchangeDiscts.tag = sender.tag;
    [self.exchangeDiscts ViewDiscountsSureBtn:@"确定取消" DiscountsConsiderBtn:@"我再想想" leftToplab:@"是否确定取消订单？"];
    [self.exchangeDiscts.DiscountsSureBtn addTarget:self action:@selector(bindingroutOnclicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.exchangeDiscts.DiscountsConsiderBtn addTarget:self action:@selector(CancelBindingRoutmeth) forControlEvents:UIControlEventTouchUpInside];
    
    [[UIApplication sharedApplication].keyWindow addSubview:self.exchangeDiscts];
}

//删除订单
- (void)DeletePayMentMeth:(UIButton *)sender{
    
    self.exchangeDelete = [[DeleteExchangeDiscount alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    self.exchangeDelete.backgroundColor = RGBA(102, 102, 102, 0.8);
    self.exchangeDelete.tag = sender.tag;
    [self.exchangeDelete ViewDeleDiscountsSureBtn:@"确定删除" DiscountsConsiderBtn:@"我再想想" leftToplab:@"是否确定删除订单？"];
    [self.exchangeDelete.DeleteDiscountsSureBtn addTarget:self action:@selector(bindingDeleteroutOnclicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.exchangeDelete.DeleteDiscountsConsiderBtn addTarget:self action:@selector(CancelBindingRoutmeth) forControlEvents:UIControlEventTouchUpInside];
    
    [[UIApplication sharedApplication].keyWindow addSubview:self.exchangeDelete];
}

//删除订单
- (void)bindingDeleteroutOnclicked:(UIButton *)sender{
    //重新请求数据
    self.exchangeDelete.hidden = YES;
    self.exchangeDiscts.hidden = YES;
    
}

- (void)CancelBindingRoutmeth{
    
    //重新请求数据
    self.exchangeDiscts.hidden = YES;
    self.exchangeDelete.hidden = YES;
}

//取消订单的接口
- (void)bindingroutOnclicked:(UIButton *)sender{
    
    //重新请求数据
    self.exchangeDiscts.hidden = YES;
    self.exchangeDelete.hidden = YES;
    
}

- (IBAction)WithoutStrollMeth:(id)sender {
    
    self.tabBarController.selectedIndex = 0;
    
}


@end
